package org.zheng.io;

import java.io.FileInputStream;

/**
 * @author zhengqn
 * @Title: 读取文件内容
 * @Description:
 * @date 2020/11/17 15:31
 */
public class IoFileInput {

    public static void main(String[] args) throws Exception{
        //读取文件
        FileInputStream fileInputStream = new FileInputStream("a.txt");
        //设置读取字节
        byte[] bytes = new byte[1024];
        int read = -1;
        //如果read的值不为-1，则说明文件中还有其他数据
        while ((read = fileInputStream.read(bytes)) != -1){
            //字节数组转换成字符串
            String str = new String(bytes, 0, read,"GBK");
            System.out.println(str);
        }
        fileInputStream.close();
    }
}
